package com.bgi.uims.module.sys.menu.dto;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

import org.apache.struts2.json.annotations.JSON;

import com.bgi.uims.common.dto.Common;

/**
 * 
 * ClassName:Resource 
 * Function: TODO 
 * Reason:	 TODO 
 * @CreateDate:2015年3月26日 下午5:30:42
 * @author   WEN
 * @version  
 * @since    JDK 1.7
 * @see
 */
public class Resource extends Common{

	/**
	 * serialVersionUID:TODO(用一句话描述这个变量表示什么).
	 * @since JDK 1.7
	 */
	private static final long serialVersionUID = 1L;
	/**
	 * 资源ID
	 */
	private String resourceId;
	/**
	 * 资源name
	 */
	private String resourceName;
	/**
	 * 资源描述
	 */
	private String resourceText;
	/**
	 * 资源URL
	 */
	private String resourceUrl;
	/**
	 * 菜单ID
	 */
	private String menuId;
	/**
	 * 创建人
	 */
	private String createUser;
	/**
	 * 创建时间
	 */
	private String createTime;
	/**
	 * 最后修改人
	 */
	private String lastModifiedUser;
	/**
	 * 最后修改时间
	 */
	private String lastModifiedTime;
	/**
	 * 辅助属性:ids
	 */
	private String[] resourceIds;
	/**
	 * 辅助属性:角色ID
	 */
	private String rolesId;
	/**
	 * 辅助属性:是否选中
	 */
	private boolean checked;
	/**
	 * 辅助属性:是否选中
	 */
	private String checkedStr;
	/**
	 * 辅助属性，历史记录时，程序单独添加记录信息
	 */
	private Map<String,String>  specialHistory;
	
	/**
	 * 将对象的信息以map形式返回，作为存储日志信息时的比较和存储
	 */
	public Map annotationObject(){
		Map<String,String> results = new HashMap<String, String>();
		results.put("object","资源");//必须有,对象描述
		results.put("table","sys_resources");//必须有,表名描述
		results.put("tableId",this.resourceId);//必须有,表名描述
		results.put("describe","资源称名"+this.resourceName);//必须有,可以指定到具体某一条，即该条的独有特性,可以描述此记录
		results.put("资源ID号", this.resourceId);
		results.put("资源名称", this.resourceName);
		results.put("资源描述", this.resourceText);
		results.put("资源URL", this.resourceUrl);
		results.put("菜单ID号", this.menuId);
		Map<String,String> extendResults = new HashMap<String, String>();
		boolean flag = true;
		if(this.specialHistory != null){
			Iterator<String> keys =  this.specialHistory.keySet().iterator();
			while(keys.hasNext()){
				String key = keys.next();
				String value = this.specialHistory.get(key);
				if(key.equals("extends") && value.equals("false")){
					flag = false;
				} else {
					extendResults.put(key, value);
				}
			}
		}
		if(flag){
			results.putAll(extendResults);
		} else {
			return extendResults;
		}
		return results;
	}
	public String getResourceId() {
		return resourceId;
	}
	public void setResourceId(String resourceId) {
		this.resourceId = resourceId;
	}
	public String getResourceName() {
		return resourceName;
	}
	public void setResourceName(String resourceName) {
		this.resourceName = resourceName;
	}
	public String getResourceText() {
		return resourceText;
	}
	public void setResourceText(String resourceText) {
		this.resourceText = resourceText;
	}
	public String getResourceUrl() {
		return resourceUrl;
	}
	public void setResourceUrl(String resourceUrl) {
		this.resourceUrl = resourceUrl;
	}
	public String getMenuId() {
		return menuId;
	}
	public void setMenuId(String menuId) {
		this.menuId = menuId;
	}
	public String getCreateUser() {
		return createUser;
	}
	public void setCreateUser(String createUser) {
		this.createUser = createUser;
	}
	public String getCreateTime() {
		return createTime;
	}
	public void setCreateTime(String createTime) {
		this.createTime = createTime;
	}
	public String getLastModifiedUser() {
		return lastModifiedUser;
	}
	public void setLastModifiedUser(String lastModifiedUser) {
		this.lastModifiedUser = lastModifiedUser;
	}
	public String getLastModifiedTime() {
		return lastModifiedTime;
	}
	public void setLastModifiedTime(String lastModifiedTime) {
		this.lastModifiedTime = lastModifiedTime;
	}
	public boolean isChecked() {
		return checked;
	}
	public void setChecked(boolean checked) {
		this.checked = checked;
	}
	public String getCheckedStr() {
		return checkedStr;
	}
	public void setCheckedStr(String checkedStr) {
		if("1".equals(checkedStr))
		{
			this.checked=true;
		}
		else
		{
			this.checked=false;
		}
		this.checkedStr = checkedStr;
	}
	public String[] getResourceIds() {
		return resourceIds;
	}
	public void setResourceIds(String[] resourceIds) {
		this.resourceIds = resourceIds;
	}
	public String getRolesId() {
		return rolesId;
	}
	public void setRolesId(String rolesId) {
		this.rolesId = rolesId;
	}
	@JSON(serialize=false)
	public Map<String, String> getSpecialHistory() {
		return specialHistory;
	}
	public void setSpecialHistory(Map<String, String> specialHistory) {
		this.specialHistory = specialHistory;
	}
	
}

